package com.xposed.aliproxy.utils;

import android.app.Activity;

import com.xposed.aliproxy.qrcode.GlobalInstance;

import java.util.ArrayList;
import java.util.Iterator;

public class ActivityUtil {
    static GlobalInstance globalInstance = GlobalInstance.getInstance();
    private static ArrayList<Activity> activities = new ArrayList();

    public static void addActivity(Activity activity) {
        if (activities == null) {
            activities = new ArrayList();
        }
        activities.add(activity);
    }

    public static void closeAll() {
        Iterator it = activities.iterator();
        while (it.hasNext()) {
            try {
                ((Activity) it.next()).finish();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
